package com.yonyou.base.common.web;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 服务调用消息结果
 *
 * @author paul.yang
 * @version 1.0 2014年9月24日
 * @since 1.6
 */
public class MessageResult {


    /**
     * 成功状态码
     */
    public static final int STATUS_SUCCESS = 200;

    /**
     * 错误状态码
     */
    public static final int STATUS_ERROR = 300;


    /**
     * 超时状态码
     */
    public static final int STATUS_TIMEOUT = 301;
    /**
     * 数据缺任码
     */
    public static final int STATUS_SUCCESS_MSG = 201;
    /**
     * 操作成功
     */
    public static final MessageResult SUCCESS = new MessageResult();

    /**
     * 操作失败
     */
    public static final MessageResult ERROR = new MessageResult(STATUS_ERROR);

    /**
     * 操作超时
     */
    public static final MessageResult TIMEOUT = new MessageResult(STATUS_TIMEOUT);

    /**
     * 操作超时
     */
    public static final MessageResult NOLOGIN = new MessageResult(306);

    /**
     * 不需要提示
     */
    public static final MessageResult SUCCESSMSG = new MessageResult("操作成功。");


    /**
     * 状态码
     */
    private int statusCode = STATUS_SUCCESS;


    /**
     * 消息
     */
    private String message = null;

    /**
     * shifouxuyaofanyi
     */
    private boolean needTranslate = true;

    /**
     * shifouweimapleixing
     */
    private boolean mapPackage = true;
    /**
     * 参数
     */
    private Object data = null;

    /**
     * 构造方法
     */
    public MessageResult() {
        this(STATUS_SUCCESS);
    }

    public MessageResult(String message) {
        this(STATUS_SUCCESS, message);
    }

    public MessageResult(int statusCode) {
        this(statusCode, null);
    }

    public MessageResult(int statusCode, String message) {
        this(statusCode, message, null);
    }

    public MessageResult(int statusCode, String message, Object data) {
        this.statusCode = statusCode;
        this.message = message;
        this.data = data;
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @JsonIgnore
    public void setMapPackage(boolean mapPackage) {
        this.mapPackage = mapPackage;
    }

    @JsonIgnore
    public void setNeedTranslate(boolean needTranslate) {
        this.needTranslate = needTranslate;
    }

}
